/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package WSModel;

/**
 *
 * @author acer
 */
public class String_Reader {

    private int lastcharidx;
    private String toread;
    public static String RELATION_PATTERN = "^(@relation) (\\S+)";
    public static String ATTRIBUTE_PATTERN = "^(@attribute) (\\S+) (\\{\\S+,\\S+\\})";
    public static String DATATAG_PATTERN = "^(@data)";
    public static String DATASET_PATTERN = "^(\\S+)((,?)(\\S+))*";

    //constructor
    public  String_Reader(String input){this.toread=input;this.lastcharidx=0;}

    public String readLine()
    {
        StringBuilder sb = new StringBuilder();
        while(lastcharidx<toread.length()&&toread.charAt(lastcharidx) != '\n')
        {
            sb.append(toread.charAt(lastcharidx));
            lastcharidx++;
        }
        lastcharidx++;
        return sb.toString();
    }
    public void reset()
    {
        this.lastcharidx = 0;
    }
    public boolean hasNextLine()
    {
        return(!(lastcharidx>=this.toread.length()));
    }
}
